﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QConnectSDK;
using QConnectSDK.Context;

namespace mscook.mvc.Core
{
    public class QQOAuth : IOAuth
    {

        #region IOAuth 成员

        public string GetAuthorizationUrl(string state, string scope)
        {
            var context = new QzoneContext();
            var authenticationUrl = context.GetAuthorizationUrl(state, scope);
            return authenticationUrl;
        }

        public OAuthUser GetUserInfoByToken(string verifierCode, string state)
        {
            var qzone = new QOpenClient(verifierCode, state);
            var QUser = qzone.GetCurrentUser();
            return new OAuthUser()
            {
                PersonID=qzone.OAuthToken.OpenId,
                LoginName = QUser.Nickname,
                MediaID="qq"

            };
        }

        #endregion
    }
    public class OAuthUser
    {
        public string PersonID
        {
            get;
            set;
        }
        public string LoginName
        {
            get;
            set;
        }
        public string MediaID
        {
            get;
            set;
        }
    }
}